<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        window.onload = function (e) {
            var imgEle = document.querySelector('#img');
            imgEle.onmouseover = function () {
                this.src = '2.jpg';
                // console.log(e);
            };
            imgEle.onmouseout = function () {
                this.src = '1.jpg';
            };
        }
    </script>
</head>
<body>
<img id="img" src="1.jpg" width="400" height="300">
</body>
</html>